-module( huangxin_check ).


-export([
        check/3
        ]).


% --------------------------------------------------
% 用户鉴权接口
% --------------------------------------------------
check( UserId, Token, PlatForm ) ->
    case UserId of
        <<"ping_user_cym">> ->
            true;
        _NotPingUser ->
            Host = util:get_value_cache( emqttd, password_check_callback, "http://120.77.200.228/authUser"),
            case  httpc:request( post, { Host, [],"application/x-www-form-urlencoded", "userId=" ++ util:a2l(UserId) ++ "&token=" ++ util:a2l(Token)},[],[]) of
                {ok,{{ _HttpVersion, 200, "OK"},_Header, "{\"errorCode\": \"0\"}"}} ->
                    true;
                _NotPasss ->
                    util:print("service check password error. UserId:~p Token:~p PlatForm:~p ~n", [UserId, Token, PlatForm]),
                    false
            end
    end.

